package welsir.common;

import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import welsir.entity.vo.ResultMessage;
import welsir.exception.ServiceException;
import welsir.util.ResultUtil;

/**
 * @author Genius
 * @date 2023/03/09 23:04
 **/
@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(value = ServiceException.class)
    public ResultMessage handler(ServiceException e) {
        System.out.println(e.getMessage());
        return ResultUtil.error(e.getResultCode().code(), e.getResultCode().message());
    }
}
